<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../css/aui.css"/>
    <title>账号登录</title>
    <style>
        body {
            /*background: url("../image/login_bg.png") no-repeat;*/
            background: url("../image/loginbg.png") no-repeat;
            width: 100%;
            height: 50px;
            background-size: 100% 100%;
            text-align: center;
            font-size: 14px;
        }

        .aui-content {
            width: 85%;
            margin-top: 100px;
            margin-left: auto;
            margin-right: auto;
            margin-bottom: 0;
        }

        .aui-form {
            position: static;
            border-radius: 5px;
            margin-bottom: 10px;
        }

        .aui-input-row {
            /*position: static;*/
            width: 100%;
        }

        .aui-input-row .aui-input-addon {
            padding-left: 15px;
        }

        .vali {
            margin-top: 4px;
            float: right;
            background-color: #fff;
            border: none;
            border-left: 1px solid #ccc;
            border-radius: 0;
            padding-left: 15px;
            padding-right: 5px;
        }

        #password {
            width: 60%;
            padding-right: 0px;
        }

        .aui-btn-block {
            padding: 8px 0px;
        }

        .aui-btn-row {
            padding: 20px 0 20px 0;
            position: static;
        }

        .login_name {
            color: #ffffff;
        }

        .aui-btn-info {
            color: #ffffff;
            background-color: #327AFA;
            border: 1px solid #327AFA;
        }

        .aui-btn-row {
            padding: 5px 0px;
        }

        .register {
            color: #fff;
            background-color: transparent;
        }

        .colorBlack {
            color: #000 !important;
        }
    </style>
</head>
<body>
<div class="aui-content">
    <div class="aui-form">
        <div class="aui-input-row" style="">
            <label class="aui-input-addon">账号</label>
            <!--<input type="tel" id="mobile" data="user" class="aui-input" placeholder="请输入手机号码" value="13903006114">-->
            <!--<input type="tel" id="mobile" data="supplier" class="aui-input" placeholder="请输入手机号码" value="18998762201">-->
            <input type="tel" id="mobile"  class="aui-input" placeholder="请输入手机号码" value="">
            <!--爱奖励-->
            <!--<input type="tel" id="mobile"  class="aui-input" placeholder="请输入手机号码" value="">-->
            <!--<input type="tel" id="mobile"  data="user" class="aui-input" placeholder="请输入手机号码" value="13824408279">-->
            <!--<input type="tel" id="mobile" data="agent"  class="aui-input" placeholder="请输入手机号码" value="18012947316">-->
        </div>
        <div class="aui-input-row ">
            <label class="aui-input-addon">密码</label>
            <input type="password" id="password" class="aui-input" placeholder="6-20位数字或字母" value=""/>

            <div class="aui-btn vali" tapmode onclick="forget()">忘记密码?</div>
        </div>
        <div class="aui-input-row aui-hide">
            <label class="aui-input-addon">登录类型</label>
            <div class="aui-padded-10 aui-text-left aui-text-default validate memberType" tapmode
                 onclick="chooseType(this)">选择你的登录类型<i class="aui-iconfont aui-icon-unfold"></i></div>

        </div>
    </div>
    <div class="aui-btn-row">
        <div class="aui-btn aui-btn-info aui-btn-block" tapmode onclick="login()">
            登录
        </div>
    </div>
    <div class="aui-btn-row ">
        <div class="aui-btn aui-btn-block register" tapmode onclick="register()">
            注册
        </div>
    </div>
</div>
<div class="login_name aui-hide">

    <span tapmode onclick="loginMobile()">动态密码登录</span>
    <i class="aui-iconfont aui-icon-roundright"></i>
</div>
</div>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script type="text/javascript" src="../script/myInfo.js"></script>
<script type="text/javascript" src="../script/jquery-1.11.3.js"></script>
<script type="text/javascript" src="../script/md5.min.js"></script>
<script type="text/javascript">
    var memberType = "";
    apiready = function () {
        api.parseTapmode();
    }
    function login() {
        var mobile = $api.val($api.byId('mobile'));
        var password = $api.val($api.byId('password'));
        var data = {};


        if (mobile.length > 0 && password.length > 0) {
            $('input').each(function () {
                $(this).blur();
            })
            api.showProgress({
                style: 'default',
                animationType: 'fade',
                title: '正在登陆...',
                text: '',
                modal: true
            });

            data['account'] = mobile;
            data['password'] = password;
            var url = 'account/login';
            ajaxRequest(url, 'post', data, function (ret, err) {
                $api.clearStorage();
                $api.setStorage('user_id', '' + ret.data.user_id + '');
                $api.setStorage("user_password", '' + ret.data.password + '');
                $api.setStorage("member_type", '' + ret.data.account_type + '');
                $api.setStorage('user_name', '' + ret.data.user_name + '');
//                $api.setStorage('group_id', '' + ret.data.groupid + '');
//                $api.setStorage('user_name', '' + ret.data.user_name + '');
//                $api.setStorage('company', '' + ret.data.company + '');
//                if(ret.data.account_type=="supplier"){
//                    $api.setStorage('companyName', '' + ret.data.supplier_info.supplier_name + '');
//                }
//                $api.setStorage('nickname', '' + ret.data.nickname + '');
//                $api.setStorage('head_pic', '' + ret.data.head_portrait + '');
//                $api.setStorage('money', '' + ret.data.user_money + '');
//                $api.setStorage('online', '' + ret.data.online + '');
//                $api.setStorage('message', '' + ret.data.message + '');
//                $api.setStorage('chat', '' + ret.data.chat + '');
//                $api.setStorage('credit', '' + ret.data.credit + '');
//                $api.setStorage('collect', '' + ret.data.collect + '');
//                $api.setStorage('rongcloud_token', '' + ret.data.rongcloud_token + '');
//                $api.setStorage('vcompany', '' + ret.data.vcompany + '');
//                $api.setStorage("real_name", '' + ret.data.real_name + '');
//
//
////                账户信息
//                //爱心值
//                $api.setStorage("jifen_left", '' + ret.data.extra_count.jifen_left + '');
//                //爱心豆
//                $api.setStorage("jifen_returned", '' + ret.data.extra_count.jifen_returned + '');
//                //总消费
//                $api.setStorage("amount_total", '' + ret.data.extra_count.amount_total + '');
//                //商家总业绩
//                $api.setStorage("amount_total", '' + ret.data.extra_count.amount_total + '');
//                //总分润
//                $api.setStorage("money_total", '' + ret.data.extra_count.money_total + '');
//                //本月分润
//                $api.setStorage("money_thismonth", '' + ret.data.extra_count.money_thismonth + '');
//                //未提货款
//                $api.setStorage("money_unwithdrawn", '' + ret.data.extra_count.money_unwithdrawn + '');
//                //已提货款
//                $api.setStorage("money_withdrawn", '' + ret.data.extra_count.money_withdrawn + '');
//                //总货款
//                $api.setStorage("money_total", '' + ret.data.extra_count.money_total + '');



                getUserInfo();
                // api.toast({
                //     msg: '登录成功',
                //     duration: 2000,
                //     location: 'bottom'
                // });
                //触发登录监听
                api.sendEvent({
                    name: 'reGetMyInfo',
                    extra: {
                        key: 'true',
                        memberType: memberType
                    }
                })
                // api.sendEvent({
                //     name: 'loginSuccess',
                //     extra: {
                //         key: 'true'
                //     }
                // });
                setTimeout(function () {
                    api.hideProgress();
                    //关闭到指定窗口，最上面显示的窗口到指定name窗口间的所有窗口都会被关闭
                    whereToGo(ret.data.account_type,"../")


                }, 1000);

            });
        } else {
            api.toast({
                msg: '请输入完整信息',
                duration: 2000,
                location: 'bottom'
            });
        }
    }

    function register() {
        api.openWin({
            name: 'register_win',
            url: 'register_win.html',
            reload: true,
            //delay: 300
        });
    }

    function loginMobile() {
        // api.openWin({
        //     name: 'loginMobile_win',
        //     url: 'loginMobile_win.html',
        //     reload: true,
        // });
        api.openWin({
            name: 'loginMobile_win',
            url: 'loginMobile_win.html',
            animation: {
                type: 'flip',
                subType: 'from_bottom',
                duration: 500
            }
        });
    }

    function forget() {
        api.openWin({
            name: 'forget_win',
            url: 'forget_win.html',
            reload: true,
            //delay: 300
        });
    }
    function chooseType(obj) {
        api.actionSheet({
            title: "请选择登录类型",
            buttons: ['商家', "代理商", "会员"]
        }, function (ret, err) {

            if (ret.buttonIndex == 1) {
                memberType = '商家';

                $(obj).removeClass("validate");
            } else if (ret.buttonIndex == 2) {
                memberType = '代理商';
                $(obj).removeClass("validate");

            } else if (ret.buttonIndex == 3) {
                memberType = '会员';
                $(obj).removeClass("validate");

            } else {
                return false;
            }
            $(obj).addClass("colorBlack");
            $(obj).html(memberType);

        });
    }
</script>
</body>
</html>